package com.yxjx.duoxue.datamodel;

import java.io.Serializable;

import org.json.JSONException;
import org.json.JSONObject;

import com.yxjx.duoxue.utils.UIHelper;

public class DMCommentReply implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 9049219042639699254L;
	private int commentId;
	private String replyText;
	private long replyTimeStamp;
	
	
	public int getCommentId() {
		return commentId;
	}
	public void setCommentId(int commentId) {
		this.commentId = commentId;
	}
	public String getReplyText() {
		return replyText;
	}
	public void setReplyText(String replyText) {
		this.replyText = replyText;
	}
	public long getReplyTimeStamp() {
		return replyTimeStamp;
	}
	public void setReplyTimeStamp(long replyTimeStamp) {
		this.replyTimeStamp = replyTimeStamp;
	}
	
	/**
	 * Parse a comment reply from json String.
	 * @param str
	 * @return
	 */
	public static DMCommentReply from(String str) {
		DMCommentReply reply = null;
		if (UIHelper.isEmpty(str)) {
			return null;
		}
		JSONObject jo;
		try {
			jo = new JSONObject(str);
			reply = new DMCommentReply();
			reply.setReplyText(jo.getString("replyText"));
			reply.setReplyTimeStamp(jo.getLong("replyTime"));
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return reply;
	}

}
